<!doctype html>
<html lang="en">
<head>
    <title>我请老师上封面！</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge，chrome=1">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../node_modules/sweetalert/dist/sweetalert.css">
    <link rel="stylesheet" href="/src/css/app.less">
    <link rel="stylesheet" href="/src/css/teacher.less">
</head>
<body>
<div class="rank disNone">
    <div class="top"></div>
    <div class="content">
        <p>*点击可查看祝福语</p>
        <ul>
            <li class="title"><span>排名</span><span>老师</span><span>学校</span><span>点赞数</span></li>
            <li v-for="(r,index) in rank" v-on:click="toShare(r.topic_id)"><span>{{index+1}}</span><span>{{r.teacher}}</span><span>{{r.school}}</span><span>{{r.like_sum}}</span></li>
        </ul>
        <p><a href="http://www.yixiaoqun.com/#/group/51">查看所有祝福</a></p>
        <div class="code">
            <img src="/src/img/teacher/code2.png" />
        </div>
    </div>

    <div class="bottom">
        <a href="javascript:void(0);" class="btn" v-on:click="back()">返回</a>
    </div>
</div>
<div class="music on">
    <audio src="../src/other/teacher/bgmusic.mp3" autoplay="autoplay" loop="loop" id="bgmusic"></audio>
</div>

<script src="/src/lib/flexible.js"></script>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/vue/dist/vue.js"></script>
<script src="../node_modules/sweetalert/dist/sweetalert-dev.js"></script>
<script src="/src/js/config.js"></script>
<script src="/src/js/teacher.js"></script>

<script>
    new Vue({
        el: '.rank',
        data: {
            rank : '',
        },
        mounted() {
            this.getData();
            if($config.iswx()){
                $config.wxShare({
                    title:'我请老师上封面！',
                    cont:'今年教师节，让我们用一种特殊的方式，感谢停留在我们内心的那位好老师。',
                    url:'',
                    logo:'http://h5.yixiaoqun.com/static/src/img/teacher/logo.jpg',
                })
            }
            $config.audioAutoPlay();
        },
        methods : {
            //获取排行榜
            getData: function(){
                var _this = this;
                $.ajax({
                    url : $config.host+'/H5/ranking',
                    type : 'post',
                    data : {
                        project: location.hostname == 'h5.yixiaoqun.com'?'jsj':'test',
                    },
                    dataType: 'jsonp',
                    success : function (json) {
                        _this.rank = json.data;

                        for(var i in json.data){
                            var cons = json.data[i].content;
                            var con = cons.split("\n");

                            try{
                                _this.rank[i].teacher = con[1].substring(3);
                                _this.rank[i].school = con[2].substring(3);
                            }catch (e){
                                _this.rank[i].teacher = '';
                                _this.rank[i].school = '';
                            }
                        }

                        $('.disNone').removeClass('disNone');
                    }
                })
            },
            toShare: function(tid){
                window.location.href='teacher_share.html?tid='+tid;
            },
            back: function(){
                window.history.go(-1);
            }
        }
    })
</script>
</body>
</html>